// components/life-exp/life-exp.js
Component({
    /**
     * 组件的属性列表
     */
    properties: {
        item: {
            type: Object,
        },
        index: {
            type: Number,
        },
        current: {
            type: Number,
        },
    },

    /**
     * 组件的初始数据
     */
    data: {
        typeArr: {
            '01': '租车',
            '02': '美食三餐',
            '03': '住宿',
            '04': '出行',
        },
        // 是否展开，默认展开
        unfold: true,
        permissionList: ['00', '01', '04', '05', '06'],
    },

    lifetimes: {
        attached: function () {
            this.setData({
                unfold: !this.data.item.ellipsis,
            });
        },
    },

    /**
     * 组件的方法列表
     */
    methods: {
        // 编辑
        edit(e) {
            let {
                uid,
                id,
                index,
                type,
                istop,
                istopall,
                dotid,
            } = e.currentTarget.dataset;

            if (dotid) {
                wx.showToast({
                    title: '请到春军扫网App编辑',
                    icon: 'none',
                    duration: 1500,
                });
                return;
            }

            this.triggerEvent('edit', {
                uid,
                id,
                index,
                type,
                istop,
                istopall,
            });
        },

        // 预览图片
        previewImage(e) {
            let index = e.currentTarget.dataset.index;
            let images = JSON.parse(e.currentTarget.dataset.images) || [];

            wx.previewImage({
                current: images[index],
                urls: images,
            });
        },

        // 展开全文
        unfold() {
            // this.setData({
            //     unfold: true,
            // });
            return;
        },
        // 导航
        navigate(e) {
            return;
            const { lat, lng, address } = e.currentTarget.dataset;
            wx.openLocation({
                latitude: lat,
                longitude: lng,
                name: '详细地址',
                address: address,
            });
        },
    },
});
